import { View } from "../../../../../mvc/core/View";
import { LayerManager } from "../../../../manager/LayerManager";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { EventName } from "../../../../mvc/EventName";
import { SArenaCrossBattleInfo } from "../../../../../../Message/Public/SArenaCrossBattleInfo";
import { AvatarInfo } from "../../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../../com/gengine/resource/info/ImageInfo";
import { CareerConfig } from "../../../../resource/CareerConfig";
import { EntityUtil } from "../../../../scene/layer/utils/EntityUtil";
import { Global } from "../../../../../../com/gengine/global/Global";
import { ObjCreate } from "../../../common/ObjCreate";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { Language } from "../../../../../../extend/language/Language";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { LittleSendFlower } from "./LittleSendFlower";
import { DataEvent } from "../../../../events/DataEvent";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { SArenaCrossFlowerNum } from "../../../../../../Message/Public/SArenaCrossFlowerNum";
import { GButton } from "../../../../../../com/mui/controls/GButton";
import { GCheckBox } from "../../../../../../com/mui/controls/GCheckBox";
type int = number;
//class BigSendFlower
    
    export  class BigSendFlower extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            Dispatcher.addEventListener(EventName.StageResize, this.onStageRisize);
            this.initView();
            this.resize();
            return;
        }

        public updateBattleInfo(arg1: SArenaCrossBattleInfo): void
        {
            var info: SArenaCrossBattleInfo;

            var loc1;
            info = arg1;
            this._sArenaCrossBattleInfo = info;
            this._oneName.text = info.miniPlayerOne.name;
            this._twoName.text = info.miniPlayerTwo.name;
            AvatarInfo.getAvatar(info.miniPlayerOne.camp, info.miniPlayerOne.sex, AvatarType.BIG, (arg1: ImageInfo): void
            {
                _oneHeadImage.bitmapData = arg1.bitmapData;
                return;
            }, info.miniPlayerOne.avatarId)
            AvatarInfo.getAvatar(info.miniPlayerTwo.camp, info.miniPlayerTwo.sex, AvatarType.BIG, (arg1: ImageInfo): void
            {
                _twoHeadImage.bitmapData = arg1.bitmapData;
                return;
            }, info.miniPlayerTwo.avatarId)
            this.updateHadSendFlower(info.hadSendFlower);
            this._oneInfoTx.text = "LV." + info.miniPlayerOne.level + "   " + CareerConfig.instance.getInfoByCode(info.miniPlayerOne.career).name;
            this._twoInfoTx.text = "LV." + info.miniPlayerTwo.level + "   " + CareerConfig.instance.getInfoByCode(info.miniPlayerTwo.career).name;
            this._oneServerTx.text = EntityUtil.getProxyName(info.miniPlayerOne.entityId);
            this._twoServerTx.text = EntityUtil.getProxyName(info.miniPlayerTwo.entityId);
            this._oneFlowerNumTx.text = info.flowerNumOne.toString();
            this._twoFlowerNumTx.text = info.flowerNumTwo.toString();
            this._oneWarfareTx.text = info.miniPlayerOne.warfare.toString();
            this._twoWarfareTx.text = info.miniPlayerTwo.warfare.toString();
            if (this._littleSendFlower) 
            {
                this._littleSendFlower.updateBattleInfo(this._sArenaCrossBattleInfo);
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show();
            if (this._littleSendFlower) 
            {
                this._littleSendFlower.hide();
            }
            return;
        }

        public hideAll(): void
        {
            this.hide();
            if (this._littleSendFlower) 
            {
                this._littleSendFlower.hide();
            }
            return;
        }

        public lockSmall(): void
        {
            if (this._sArenaCrossBattleInfo) 
            {
                this.miniSize();
            }
            return;
        }

        /* internal  */onStageRisize(arg1: Object /* flash.events.Event */): void
        {
            this.resize();
            this._littleSendFlower.resize();
            return;
        }

        /* internal  */resize(): void
        {
            this.x = (Global.stage.stageWidth - this.width) * 0.5;
            this.y = (Global.stage.stageHeight - this.height) * 0.5;
            return;
        }

        /* internal  */initView(): void
        {
            var loc1=null;
            ObjCreate.createBg(0, 0, 365, 350, this, ImagesConst.ToolTipBg);
            ObjCreate.createBg(180, 36, 400, 3, this, ImagesConst.Line).rotation = 90;
            this._minusBtn = ObjCreate.createGButton("", 335, 5, 19, 19, this, "MinusBtn");
            this._minusBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onMinusBtnClickHandler);
            this._oneName = ObjCreate.createTextField("", 40, 40, 108, 20, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._twoName = ObjCreate.createTextField("", 214, 40, 108, 20, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            loc1 = new Object /* flash.display.Bitmap */();
            loc1.x = 37;
            loc1.y = 46;
            this.addChild(loc1);
            LoaderHelp.setBitmapdata("Friend_Bg_Head.swf", loc1);
            var loc2=new Object /* flash.display.Bitmap */();
            loc2.x = 208;
            loc2.y = 46;
            this.addChild(loc2);
            LoaderHelp.setBitmapdata("Friend_Bg_Head.swf", loc2);
            this._oneHeadImage = new Object /* flash.display.Bitmap */();
            this._twoHeadImage = new Object /* flash.display.Bitmap */();
            this._oneHeadImage.x = 56;
            this._oneHeadImage.y = 64;
            this._twoHeadImage.x = 225;
            this._twoHeadImage.y = 64;
            this.addChild(this._oneHeadImage);
            this.addChild(this._twoHeadImage);
            this._oneInfoTx = ObjCreate.createTextField("", 47, 154, 100, 20, this, GlobalStyle.textFormat6);
            this._twoInfoTx = ObjCreate.createTextField("", 225, 154, 100, 20, this, GlobalStyle.textFormat6);
            var loc3=ObjCreate.createTextField(Language.getString(42288), 47, 176, 52, 20, this, GlobalStyle.textFormat6);
            var loc4=ObjCreate.createTextField(Language.getString(42288), 225, 176, 52, 20, this, GlobalStyle.textFormat6);
            this._oneServerTx = ObjCreate.createTextField("", 99, 176, 72, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65535));
            this._twoServerTx = ObjCreate.createTextField("", 277, 176, 72, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65535));
            var loc5=ObjCreate.createTextField(Language.getString(42289), 47, 196, 52, 20, this, GlobalStyle.textFormat6);
            var loc6=ObjCreate.createTextField(Language.getString(42289), 225, 196, 52, 20, this, GlobalStyle.textFormat6);
            this._oneWarfareTx = ObjCreate.createTextField("", 99, 196, 72, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16744512));
            this._twoWarfareTx = ObjCreate.createTextField("", 277, 196, 72, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16744512));
            this._stFlowerBmI = ObjCreate.createBitmap("", 56, 236, this);
            this._stFlowerBmII = ObjCreate.createBitmap("", 228, 236, this);
            this._oneFlowerNumTx = ObjCreate.createTextField("", 106, 235, 60, 22, this, new GTextFormat(FontUtil.stXingkaiName, 20, GlobalStyle.color5Uint));
            this._twoFlowerNumTx = ObjCreate.createTextField("", 274, 235, 60, 22, this, new GTextFormat(FontUtil.stXingkaiName, 20, GlobalStyle.color5Uint));
            this._oneSendFlowerBtn = ObjCreate.createGButton(Language.getString(42290), 68, 272, 52, 20, this);
            this._twoSendFlowerBtn = ObjCreate.createGButton(Language.getString(42290), 252, 272, 52, 20, this);
            this._oneNoNameBox = ObjCreate.createCheckBox(Language.getString(42291), 54, 304, 160, 20, this);
            this._oneNoNameBox.textField.filters = [FilterConst.glowFilter];
            this._twoNoNameBox = ObjCreate.createCheckBox(Language.getString(42291), 239, 304, 160, 20, this);
            this._twoNoNameBox.textField.filters = [FilterConst.glowFilter];
            var loc7=ObjCreate.createTextField(Language.getString(42292), 96, 327, 192, 20, this, GlobalStyle.textFormat5);
            this._oneSendFlowerBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSendFlowerClick);
            this._twoSendFlowerBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSendFlowerClick);
            LoaderHelp.addResCallBack(ResFileConst.ArenaCrossGroupSendFlowers, this.onLoadBmResource);
            return;
        }

        protected onMinusBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.miniSize();
            return;
        }

        public miniSize(): void
        {
            if (!this._littleSendFlower) 
            {
                this._littleSendFlower = new LittleSendFlower();
                this._littleSendFlower.updateBattleInfo(this._sArenaCrossBattleInfo);
            }
            this._littleSendFlower.show();
            this.hide();
            return;
        }

        protected onSendFlowerClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._oneSendFlowerBtn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGroupSendFlower, {"entityId": this._sArenaCrossBattleInfo.miniPlayerOne.entityId, "bool": this._oneNoNameBox.selected}));
                    break;
                }
                case this._twoSendFlowerBtn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGroupSendFlower, {"entityId": this._sArenaCrossBattleInfo.miniPlayerTwo.entityId, "bool": this._twoNoNameBox.selected}));
                    break;
                }
            }
            this.miniSize();
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stFlowerBmI.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossSFFlowers);
            this._stFlowerBmII.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossSFFlowers);
            return;
        }

        public updateInfo(arg1: SArenaCrossFlowerNum): void
        {
            var loc1=EntityUtil.toString(arg1.entityId);
            var loc2=EntityUtil.toString(this._sArenaCrossBattleInfo.miniPlayerOne.entityId);
            var loc3=EntityUtil.toString(this._sArenaCrossBattleInfo.miniPlayerTwo.entityId);
            if (loc1 != loc2) 
            {
                if (loc1 == loc3) 
                {
                    this._sArenaCrossBattleInfo.flowerNumTwo = arg1.flowerNum;
                }
            }
            else 
            {
                this._sArenaCrossBattleInfo.flowerNumOne = arg1.flowerNum;
            }
            this.updateBattleInfo(this._sArenaCrossBattleInfo);
            return;
        }

        public updateSendSuccess(): void
        {
            if (this._sArenaCrossBattleInfo) 
            {
                this._sArenaCrossBattleInfo.hadSendFlower = true;
            }
            this.updateBattleInfo(this._sArenaCrossBattleInfo);
            return;
        }

        public updateHadSendFlower(arg1: Boolean): void
        {
            if (arg1) 
            {
                this._oneSendFlowerBtn.enabled = false;
                this._twoSendFlowerBtn.enabled = false;
            }
            else 
            {
                this._oneSendFlowerBtn.enabled = true;
                this._twoSendFlowerBtn.enabled = true;
            }
            return;
        }

        /* internal */ /* var */_sArenaCrossBattleInfo: SArenaCrossBattleInfo;

        /* internal */ /* var */_minusBtn: GButton;

        /* internal */ /* var */_oneName: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoName: Object /* flash.text.TextField */;

        /* internal */ /* var */_oneHeadImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_twoHeadImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_oneInfoTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoInfoTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_oneServerTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoServerTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_oneWarfareTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoWarfareTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_stFlowerBmI: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stFlowerBmII: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_oneFlowerNumTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoFlowerNumTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_oneSendFlowerBtn: GButton;

        /* internal */ /* var */_twoNoNameBox: GCheckBox;

        /* internal */ /* var */_littleSendFlower: LittleSendFlower;

        /* internal */ /* var */_oneNoNameBox: GCheckBox;

        /* internal */ /* var */_twoSendFlowerBtn: GButton;
    }
